package com.yc.chatroom.server.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yc.chatroom.common.dto.ResultDto;
import com.yc.chatroom.common.dto.RegisterDto;
import com.yc.chatroom.server.pojo.po.UserPo;
import com.yc.chatroom.server.service.UserService;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	private UserService userService;

	/**
	 * 注册用户
	 * @param dto
	 * @return
	 */
	@PostMapping("/register")
	public ResultDto register(@RequestBody RegisterDto dto) {
		
		return userService.register(dto);
	}
	
	@PostMapping("/get")
	public ResultDto get() {
		List<UserPo> userPoList = new ArrayList<>();
		ResultDto res = new ResultDto();
		res.setData(userService.get());
		return res;
	}
}
